<p>This is an issue when using <code>FileReader#readAsArrayBuffer()</code> or <code>FileReader#readAsText()</code> without additional parameters, as
these can be replaced with simpler Promise-based alternatives.</p>
<h2>Why is this an issue?</h2>
<p>The <code>FileReader</code> API was designed before promises became standard in JavaScript. It requires verbose callback-based code with event
listeners for 'load' and 'error' events.</p>
<p>The newer <code>Blob#arrayBuffer()</code> and <code>Blob#text()</code> methods return promises directly, making the code much cleaner and easier to
understand. They eliminate the need for:</p>
<ul>
  <li> Creating FileReader instances </li>
  <li> Setting up event listeners </li>
  <li> Wrapping everything in Promise constructors </li>
  <li> Handling both success and error callbacks </li>
</ul>
<p>This modernization improves code readability and reduces the chance of errors in promise handling. The newer methods are well-supported in modern
browsers and provide the same functionality with less boilerplate code.</p>
<h3>What is the potential impact?</h3>
<p>Using outdated FileReader patterns makes code unnecessarily complex and harder to maintain. The verbose callback-based approach increases the
likelihood of errors in promise handling and makes the codebase less consistent with modern JavaScript practices.</p>
<h3>How to fix?</h3>
<p>Replace FileReader#readAsArrayBuffer() with the simpler Blob#arrayBuffer() method that returns a promise directly.</p>
<h4>Non-compliant code example</h4>
<pre data-diff-id="1" data-diff-type="noncompliant">
const arrayBuffer = await new Promise((resolve, reject) =&gt; {
  const fileReader = new FileReader();
  fileReader.addEventListener('load', () =&gt; {
    resolve(fileReader.result);
  });
  fileReader.addEventListener('error', () =&gt; {
    reject(fileReader.error);
  });
  fileReader.readAsArrayBuffer(blob); // Noncompliant
});
</pre>
<h4>Compliant code example</h4>
<pre data-diff-id="1" data-diff-type="compliant">
const arrayBuffer = await blob.arrayBuffer();
</pre>
<h3>Documentation</h3>
<ul>
  <li> <a href="https://github.com/sindresorhus/eslint-plugin-unicorn#readme">eslint-plugin-unicorn</a> - Rule <a
  href="https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-blob-reading-methods.md">prefer-blob-reading-methods</a>
  </li>
  <li> Blob.arrayBuffer() - MDN - <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob/arrayBuffer">Documentation for the modern
  Blob.arrayBuffer() method</a> </li>
  <li> Blob.text() - MDN - <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob/text">Documentation for the modern Blob.text() method</a>
  </li>
  <li> FileReader - MDN - <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader">Documentation for the legacy FileReader API</a> </li>
</ul>
